﻿using System;

namespace Program05_新_
{
    class Program
    {
        static void Main(string[] args)
        {
            //可以无限判断

            //性别
            string gender;
            //身高
            int height;
            //体重
            int weight;
            //判断用户的性别
            Console.WriteLine("请输入你的性别（男/女）:");
            gender = Console.ReadLine();

            while (!(gender == "男" || gender == "女"))
            {
                Console.WriteLine("您输入的性别不合法，请重新输入！");
                gender = Console.ReadLine();
            }
            //判断用户的身高
            Console.WriteLine("请输入您的身高：");
            while (!(int.TryParse(Console.ReadLine(), out height) && height > 50))
            {
                Console.WriteLine("您输入的身高不合法，请重新输入！");
            }
            //判断用户的体重
            Console.WriteLine("请输入你的体重：");
            while (!(int.TryParse(Console.ReadLine(), out weight) && weight > 20))
            {
                Console.WriteLine("您输入的体重不合法，请重新输入！");
            }
            //输出判断健康信息
            //调用方法
            string message = DetectWeight(GetStandardWeight(gender, height, weight), weight);

            Console.WriteLine("您的健康状况是：" + message);
        }
        /// <summary>
        /// 计算标准体重
        /// </summary>
        /// <param name="gender">性别</param>
        /// <param name="height">身高</param>
        /// <param name="weight">体重</param>
        /// <returns></returns>

        public static int GetStandardWeight(string gender, int height, int wweight)
        {
            int standardWeight;
            if(gender=="男")
            {
                //男士的标准体重
                standardWeight = (height - 80) * 7/10;
            }
            else
            {
                //女士的标准体重
                standardWeight = (height - 70) * 3/5;
            }
            return standardWeight;
        }
        /// <summary>
        /// 检查健康状态
        /// </summary>
        /// <param name="standardWeight">标准体重</param>
        /// <param name="weight">用户体重</param>
        /// <returns></returns>
        public static string DetectWeight(int standardWeight, int weight)
        {
            string message = "";
            if (weight - standardWeight > 0)
            {
                //体重正常，体重过重，肥胖
                if (weight < standardWeight * 11 / 10)
                {
                    message = "体重正常";
                }
                else
                {
                    if (weight > standardWeight * 11 / 10 && weight < standardWeight * 12 / 10)
                    {
                        message = "体重过重";
                    }
                    else
                    {
                        message = "肥胖"; 
                    }
                }
            }
            else
            {
                //体重正常，体重过轻，体重不足
                if (weight > standardWeight * 9 / 10)
                {
                    message = "体重正常";
                }
                else
                {
                    if (weight < standardWeight * 9 / 10 && weight > standardWeight * 8 / 10)
                    {
                        message = "体重过轻";
                    }
                    else
                    {
                        message = "体重不足";
                    }
                }
            }

            return message;
        }
    }
    
}
